﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Himp.Platform.Migrations
{
    /// <inheritdoc />
    public partial class modify_table_StdModelAssocPhrDict_nullable : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_MainStdModelAssocPhrDict_MainStdModelDict_StdModelConfigId",
                table: "MainStdModelAssocPhrDict");

            migrationBuilder.DropForeignKey(
                name: "FK_MainStdPhrDict_MainStdModelAssocPhrDict_StdModelAssocPhrDic~",
                table: "MainStdPhrDict");

            migrationBuilder.DropIndex(
                name: "IX_MainStdPhrDict_StdModelAssocPhrDictId",
                table: "MainStdPhrDict");

            migrationBuilder.DropColumn(
                name: "StdModelAssocPhrDictId",
                table: "MainStdPhrDict");

            migrationBuilder.RenameColumn(
                name: "StdModelConfigId",
                table: "MainStdModelAssocPhrDict",
                newName: "StdPhrDictID");

            migrationBuilder.RenameIndex(
                name: "IX_MainStdModelAssocPhrDict_StdModelConfigId",
                table: "MainStdModelAssocPhrDict",
                newName: "IX_MainStdModelAssocPhrDict_StdPhrDictID");

            migrationBuilder.AddColumn<bool>(
                name: "NullableFlag",
                table: "MainStdModelAssocPhrDict",
                type: "boolean",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn<bool>(
                name: "PkFlag",
                table: "MainStdModelAssocPhrDict",
                type: "boolean",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn<Guid>(
                name: "StdModelDictId",
                table: "MainStdModelAssocPhrDict",
                type: "uuid",
                nullable: false,
                defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));

            migrationBuilder.CreateIndex(
                name: "IX_MainStdModelAssocPhrDict_StdModelDictId",
                table: "MainStdModelAssocPhrDict",
                column: "StdModelDictId");

            migrationBuilder.AddForeignKey(
                name: "FK_MainStdModelAssocPhrDict_MainStdModelDict_StdModelDictId",
                table: "MainStdModelAssocPhrDict",
                column: "StdModelDictId",
                principalTable: "MainStdModelDict",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_MainStdModelAssocPhrDict_MainStdPhrDict_StdPhrDictID",
                table: "MainStdModelAssocPhrDict",
                column: "StdPhrDictID",
                principalTable: "MainStdPhrDict",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_MainStdModelAssocPhrDict_MainStdModelDict_StdModelDictId",
                table: "MainStdModelAssocPhrDict");

            migrationBuilder.DropForeignKey(
                name: "FK_MainStdModelAssocPhrDict_MainStdPhrDict_StdPhrDictID",
                table: "MainStdModelAssocPhrDict");

            migrationBuilder.DropIndex(
                name: "IX_MainStdModelAssocPhrDict_StdModelDictId",
                table: "MainStdModelAssocPhrDict");

            migrationBuilder.DropColumn(
                name: "NullableFlag",
                table: "MainStdModelAssocPhrDict");

            migrationBuilder.DropColumn(
                name: "PkFlag",
                table: "MainStdModelAssocPhrDict");

            migrationBuilder.DropColumn(
                name: "StdModelDictId",
                table: "MainStdModelAssocPhrDict");

            migrationBuilder.RenameColumn(
                name: "StdPhrDictID",
                table: "MainStdModelAssocPhrDict",
                newName: "StdModelConfigId");

            migrationBuilder.RenameIndex(
                name: "IX_MainStdModelAssocPhrDict_StdPhrDictID",
                table: "MainStdModelAssocPhrDict",
                newName: "IX_MainStdModelAssocPhrDict_StdModelConfigId");

            migrationBuilder.AddColumn<Guid>(
                name: "StdModelAssocPhrDictId",
                table: "MainStdPhrDict",
                type: "uuid",
                nullable: true);

            migrationBuilder.CreateIndex(
                name: "IX_MainStdPhrDict_StdModelAssocPhrDictId",
                table: "MainStdPhrDict",
                column: "StdModelAssocPhrDictId");

            migrationBuilder.AddForeignKey(
                name: "FK_MainStdModelAssocPhrDict_MainStdModelDict_StdModelConfigId",
                table: "MainStdModelAssocPhrDict",
                column: "StdModelConfigId",
                principalTable: "MainStdModelDict",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_MainStdPhrDict_MainStdModelAssocPhrDict_StdModelAssocPhrDic~",
                table: "MainStdPhrDict",
                column: "StdModelAssocPhrDictId",
                principalTable: "MainStdModelAssocPhrDict",
                principalColumn: "Id");
        }
    }
}
